﻿function ReportViewerStaticClass() {
}
ReportViewerStaticClass.Command = null;
ReportViewerStaticClass.Param = null;

//打开文件事件
ReportViewerStaticClass.OpenFile = function (path) {
    if (path) {
        ReportViewerStaticClass.Param = path;
        ReportViewerStaticClass.Command = "open";
        if (!spreadsheet.InCallback())
            spreadsheet.PerformCallback({ "command": ReportViewerStaticClass.Command, "param": path });
    }
};
//新建文件事件
ReportViewerStaticClass.CreateNew = function () {
    ReportViewerStaticClass.Command = "create";
    if (!spreadsheet.InCallback())
        spreadsheet.PerformCallback({ "command": ReportViewerStaticClass.Command, "param": "" });
};
ReportViewerStaticClass.OnSpreadsheetBeginCallback = function (s, e) {
    e.customArgs["param"] = ReportViewerStaticClass.Command;
    e.customArgs["param"] = ReportViewerStaticClass.Param;
    ReportViewerStaticClass.Param = null;
    ReportViewerStaticClass.Command = null;
};
ReportViewerStaticClass.OnSpreadsheetEndCallback = function (s, e) {
    if (ReportViewerStaticClass.Command != null)
        spreadsheet.PerformCallback();
};

//Menu事件
ReportViewerStaticClass.SpreadSheet_CuntomCommand = function (s, e) {
    switch (e.commandName) {
        case "HourDataLink":
            $('#hourModal').modal('show');
            break;
        case "DayDataLink":
            $('#dayModal').modal('show');
            break;
        case "MonthDataLink":
            $('#monthModal').modal('show');
            break;
    }
};
ReportViewerStaticClass.SetActiveCellValue = function (spreadsheet, cellValue) {
    var stateController = spreadsheet.getStateController();
    stateController.setEditMode(ASPxClientSpreadsheet.StateController.Modes.Edit);
    spreadsheet.setElementsValue(cellValue);
};
ReportViewerStaticClass.GetTree = function (orgnodes, newnodes) {
    orgnodes.forEach(function (item, index) {
        if (item.hasOwnProperty('Nodes')) {
            var newnode = {
                text: item.Text, nodes: new Array(), selectable: false, icon: "glyphicon glyphicon-folder-open"
            };
            newnodes.push(newnode);
            ReportViewerStaticClass.GetTree(item.Nodes, newnode.nodes);
        } else if (item.hasOwnProperty('Location')) {
            var newnode = {
                text: item.Text, location: item.Location, selectable: true, icon: "glyphicon glyphicon-edit"
            };
            newnodes.push(newnode);
        }
    });
};